<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=9" />
		<meta http-equiv="pragma" content="no-cache" />
		<title>内容模块管理</title>
		<%@ include file="../../../common/Admin-list.jsp"%> 	
 		<script type="text/javascript">
			$(function(){
				//模块列表
				$('#dataGridSys').datagrid({		
					height:'480',					
					rownumbers:true,//设置为true将显示行数					
					striped:true, //设置为true将交替显示行背景
					fitColumns:true,//设置为true将自动使列适应表格宽度以防止出现水平滚动
					animate:true,
					collapsible:true,
					idField:'id',//id字段
					pagination : true,//分页控件
					pageSize : 10,
				    pageList : [10, 20, 30],
				    url : '../SiteContent/list.json',
					loadMsg : '数据装载中......',
					singleSelect : true,//设置为 true，则只允许选中一行	
					toolbar: [{
						text: '新增 内容',
						iconCls: 'icon-add',
						handler: function(){	
							art.dialog.open('../SiteContent/addInterface.htm?type=add',{
										title: '',
										lock:true,
									  	width: '95%',
									    height: '95%'												   												   
									});
						}
					}],	
					columns:[[					          	
								{field:'id',title:'编号',editor:{type:'text'}},
								{field:'title',title:'标题',width:100,align:'center',editor:{type:'text'}}, 
								{field:' ',title:'预览',width:250,align:'left',editor:{type:'text'},	
									formatter:function(value,row,index){										
										var url="SiteIndex/content.htm?id="+encode64((row.id).toString());									
										var html='<a href="<%=basePath %>'+url+'&preview=yes" target="_blank" ><img src="<%=basePath %>pages/Admin/Images/search.gif" title="点击预览" style="margin-bottom:-3px"> &nbsp;</a>'+url;				   
										return html;						    	
							    	}
								},
								{field:'tag',title:'标签',width:100,align:'center',editor:{type:'text'}}, 
								{field:'issue',title:'启用',width:20,align:'center',editor:{type:'text'},
									 formatter:function(value,row,index){						    	
									    	if (value){
									    		var ss;
									    		if(value){
									    			ss='<span disabled="disabled"><input type="checkbox" checked="checked" disabled="disabled"></span> ';
									    		}else{
									    			ss='<span disabled="disabled"><input type="checkbox" disabled="disabled"></span> ';
									    		}
										    	return ss;
									    	} else {
										    	return '';
									    	}
								    	}
								},							
								{field:'opt',title:'操作',width:80,align:'center',  
				                    formatter:function(value,rec,index){
				                    	
				                    	var edit='<a title="编辑" onclick="edit(\''+ rec.id + '\')"  href="#">'+
				                    			'<img src="<%=basePath %>pages/Admin/Images/Icon/edit.gif" alt="Edit"></a>&nbsp;&nbsp;';
				                    	
				                        var dele='<a title="删除" onclick="del(\''+ rec.id +'\')"  href="#">'+
				                        		'<img src="<%=basePath %>pages/Admin/Images/Icon/delete.gif" alt="Delete"></a>&nbsp;&nbsp;';	
				                                             
				                        return edit+dele;  
				                    }  
				                 }								
					        ]]	
				});			
			})
			
		 
			
			function del(index){  //删除操作
				art.dialog({
					icon: 'question',	
					width:250,
				    content: '你确定删除该数据？',
				    ok: function () {				    	
				    	$.ajax({
							type:'POST',
							dataType:'json',
							async:false,
							url:'../SiteContent/delete.json',
							data:{ids:index,delSub:true},
							success:function(data){
								if(data.success=true){									
									art.dialog.alert('删除成功！');
									window.location.reload();  
									
								}else{
									art.dialog.alert('删除失败，请联系管理员！');
								}
							}
						});
						
				    },
				    cancelVal: '取消',
				    cancel: true //为true等价于function(){}
				});
			
          	} 
			
			function edit(index){  //编辑  
				art.dialog.open('../SiteContent/updateInterface.htm?type=edit&id='+index,{
					title: '',
					lock:true,
				  	width: '95%',
				    height: '95%'												   												   
				});
          	} 			
			
		</script>	
	</head>
	<body>
		<div>					
			<table id="dataGridSys" width="100%" height="100%"></table>			
		</div>
	</body>
</html>